﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[RequireComponent(typeof(ScrollRect))]
public class AutoScroll : MonoBehaviour
{
	private RectTransform content;
	private ScrollRect scrollRect;

	// Use this for initialization
	void Start()
	{
		scrollRect = GetComponent<ScrollRect>();
		content = scrollRect.content;
	}
	
	// Update is called once per frame
	void FixedUpdate()
	{
		if (MidiDriver.sharedInstance != null && MidiDriver.sharedInstance.IsPlaying)
		{
			foreach (RectTransform item in content)
			{
				item.anchoredPosition -= Vector2.up * MidiDriver.sharedInstance.Speed * Time.deltaTime;
			}
		}
	}
}
